package com.hc.controller;

import com.hc.entity.Auth;
import com.hc.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private AuthService authService;


    @RequestMapping("/list")
    public ModelAndView list(ModelAndView mav) {
        return mav;
    }

    @RequestMapping("/detail")
    public ModelAndView detail(ModelAndView mav, Integer id) {
        Auth auth = authService.getAuthById(id);
        mav.setViewName("auth_detail");
        mav.addObject("auth",auth);
        return mav;
    }

    @RequestMapping("/add")
    public ModelAndView add(ModelAndView mav) {
        return mav;
    }

    @RequestMapping("/update")
    public ModelAndView update(ModelAndView mav) {
        return mav;
    }

    @RequestMapping("/delete")
    public ModelAndView delete(ModelAndView mav, Integer id) {
        return mav;
    }

//<key,List<>>
    //74--super
    //add update delete
    @RequestMapping("/getAuthByRoleId")
    //flag=true查询出来全部，否则查询出来部分
    public ModelAndView getAuthByRoleId(ModelAndView mav, Integer roleId,Boolean flag) {
        Map<Auth,List<Auth>> authMap = authService.getAuthByRoleId(roleId);
        mav.setViewName("auth_list");
        mav.addObject("authMap",authMap);
        return mav;
    }
}
